cmake_minimum_required( VERSION 2.8 )
project(on_board_system)

set( CMAKE_CXX_FLAGS "-std=c++14" )

set(CMAKE_C_FLAGS "-pthread -std=gnu99")
set(CMAKE_EXE_LINKER_FLAGS "-pthread")
set(CMAKE_C_COMPILER "gcc")
set(CMAKE_CXX_COMPILER "g++")

execute_process(COMMAND uname -m
        OUTPUT_VARIABLE DEVICE_SYSTEM_ID)
message(WARNING " device system id: ${DEVICE_SYSTEM_ID}")

if (DEVICE_SYSTEM_ID MATCHES x86_64)
    add_definitions(-DPLATFORM_ARCH_x86_64=1)
elseif (DEVICE_SYSTEM_ID MATCHES aarch64)
    add_definitions(-DPLATFORM_ARCH_aarch64=1)
else ()
    message(FATAL_ERROR "FATAL: Please confirm your platform.")
endif ()


find_package( OpenCV 3 REQUIRED )


# for ekf type , here use Pdot = F * P * F' + Q
add_definitions(-DEKF_UPDATE_DISCRETE)

include_directories( 
	src
	mavlink_build/include/v2.0
	src/circularBuf
	src/mountSiyi
	src/pid
	src/ekf
	src/siftApi
	src/assistLandMode
  	${OpenCV_INCLUDE_DIRS}
  )

add_library(circular_buf STATIC src/circularBuf/circular_buf.cpp)
add_library(pid STATIC src/pid/pid.cpp)
add_library(ekf STATIC src/ekf/ekf.cpp  src/ekf/matrix.cpp)

add_executable(on_board_system  	src/main.cpp
									src/apm_flight_handler.cpp
									src/mountSiyi/mount_siyi.cpp
									src/mountSiyi/crc.cpp
									src/siftApi/sift_api.cpp
									src/assistLandMode/assist_land.cpp)


target_link_libraries( on_board_system  ${OpenCV_LIBS}
										circular_buf
										pid
										ekf)


#mount siyi test
add_executable(mount_siyi_test 		src/mount_siyi_test.cpp
									src/mountSiyi/mount_siyi.cpp
									src/mountSiyi/crc.cpp)

target_link_libraries(mount_siyi_test 	${OpenCV_LIBS}
										circular_buf)